#include <stdio.h>
#include <math.h>
int main()
{
	FILE *file = fopen("sinrom.mif","w");
	if (!file)
	{
		printf("error opening file");
		return 0;
	}
	fprintf(file,"DEPTH =1024;\nWIDTH = 10;\nADDRESS_RADIX = DEC;\nDATA_RADIX =DEC;\nCONTENT\nBEGIN\n");
	float s;
	int scaledValue;
	int i;
	for (i=0;i < 1024;i++)
	{
		s=sin(atan(1)*8*i/1024);
		scaledValue = (int)((s+1)*1023/2);
		printf("%d : %d;\n",i,scaledValue);
		fprintf(file,"%d : %d;\n",i,scaledValue);
	}
	fprintf(file,"END;\n");
	fclose(file);
	return 0;
}


